<?php
class Controller
{
	private $_file = NULL, $_valid = false;

	function __construct($file = NULL)
	{
		if ($file === NULL)
		{
			$this->_file = DIR . FILE;
		}
		else
		{
			$this->_file = $file;
		}

		foreach (Registry::get("controller/append") as $s)
		{
			if (   $s != ""
			    && file_exists("app/Controller/" . $this->_file . $s . ".php")
			    )
			{
				$this->_file .= $s;
			}
		}
	}

	function __toString()
	{
		global $site;
		if (file_exists("app/Controller/" . $this->_file . ".php"))
		{
			ob_start();
			include "app/Controller/" . $this->_file . ".php";
			return ob_get_clean();
		}
		else
		{
			return (string) new View($this->_file);
		}
	}
}